package nz.ac.massey.groupproject.ecs2;

public class SpawnerSystem implements ECSSystem {

	public void tick(ECSWorld world, SpawnerComponent spa, Position pos) {
		spa.cooldown = Math.max(0, spa.cooldown - 1);
		if (spa.cooldown <= 0) {
			spa.cooldown = 30;

			double angle = 45 * Math.PI / 180.0;
			int vx = (int) Math.round(spa.thing_speed *  Math.cos(angle));
			int vy = (int) Math.round(spa.thing_speed *  Math.sin(angle));
			var t = EntFactory.linearBbThingie(pos.x, pos.y, vx, vy);
			world.add(t);

		}
	}
}
